package com.tpc.dao.core;

/**
 * @version 0.0.1
 * @author frederic.fortin
 * @modified 2010-09-01
 */

import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.tpc.dao.extend.Tag;

public class Organisation implements IsSerializable {

     private int id;
     private String name;
     private String description;
     private int parentId;
     private int life;
     private Date created_date;
     private Date modified_date;
     // We need to do it because GWT doesn't support java.text so we need to transform dates inside de servlet
     private String createdDateString;
     private String modifiedDateString;
     private int created_by;
     private int modified_by;
     private Address address;
     private Ressource ressource;
     private Url web_site;
     private Url email;
     private Phone phone;
     private Phone fax;
     private Currency currency;
     private com.tpc.dao.extend.Tag Type;
     private com.tpc.dao.extend.Tag Category;
     private Boolean validated = false;

    public Organisation() {

    }

    public Organisation(int param) {
        id = param;
    }

    public Organisation(String param,String param1,String param2) {
        name = param;
        address = new Address();
        address.setCityName(param1);
        address.setStateName(param2);
    }

    public Organisation(int idP,String namep,String param,String param1,String param2,String param3,String param4,String param5) {
        id = idP;
        name = namep;
        address = new Address();
        address.setStreet(param);
        address.setSuite(param1);
        address.setCityName(param2);
        address.setStateName(param3);
        address.setCountryName(param4);
        address.setZipcode(param5);

    }

    public void setValidated(Boolean param) {
    	validated = param;
    }
    public Boolean isValidated() {
    	return validated;
    }
    
    public int getId() {
        return id;
    }
    public void setId(int param) {
        id = param;
    }

    public com.tpc.dao.extend.Tag getType() {
    	return Type;
    }
    public void setType(int param,String param2) {
    	Type = new Tag();
    	Type.setId(param);
    	Type.setName(param2);
    }
    
    public com.tpc.dao.extend.Tag getCategory() {
    	return Category;
    }
    public void setCategory(int param,String param2) {
    	Category = new Tag();
    	Category.setId(param);
    	Category.setName(param2);
    }
    
    public String getName() {
        return name;
    }
    public void setName(String param) {
        name = param;
    }

    public String getDescription() {
        if (description == null) {
            description = "";
        }
        return description;
    }
    public void setDescription(String param) {
        description = param;
    }

    public int getParentId() {
        return parentId;
    }
    public void setParentId(int param) {
        parentId = param;
    }

    public Currency getCurrency() {
        return currency;
    }
    public void setCurrency(int param,String param1,String param2) {
        currency = new Currency();
        currency.setId(param);
        currency.setCode(param1);
        currency.setName(param2);
    }

    public Address getAddress() {
        return address;
    }
    public void setAddress(int idp,String streetp,String suitep,String zipcodep,String citynamep,String statenamep) {
        address = new Address();
        address.setId(idp);
        address.setStreet(streetp);
        address.setSuite(suitep);
        address.setZipcode(zipcodep);
        address.setCityName(citynamep);
        address.setStateName(statenamep);
    }
    public void setAddress(int idp,String streetp,String suitep,String zipcodep,String citynamep,String statenamep,String countrynamep) {
        address = new Address();
        address.setId(idp);
        address.setStreet(streetp);
        address.setSuite(suitep);
        address.setZipcode(zipcodep);
        address.setCityName(citynamep);
        address.setStateName(statenamep);
        address.setCountryName(countrynamep);
    }
    public void setAddress(int idp,String streetp,String suitep,int zipcodeIdp) {
        address = new Address();
        address.setId(idp);
        address.setStreet(streetp);
        address.setSuite(suitep);
        address.setZipcodeId(zipcodeIdp);
    }
    public void setAddress(int idp,String streetp,String suitep,String zipcodep,int zipcodeIdp,String citynamep,String statenamep,String countrynamep) {
        address = new Address();
        address.setId(idp);
        address.setStreet(streetp);
        address.setSuite(suitep);
        address.setZipcode(zipcodep);
        address.setZipcodeId(zipcodeIdp);
        address.setCityName(citynamep);
        address.setStateName(statenamep);
        address.setCountryName(countrynamep);
    }
    public void setAddress(int idp,String streetp,String suitep,String zipcodep,int zipcodeIdp,String citynamep,String statenamep,String countrynamep,int countryId) {
        address = new Address();
        address.setId(idp);
        address.setStreet(streetp);
        address.setSuite(suitep);
        address.setZipcode(zipcodep);
        address.setZipcodeId(zipcodeIdp);
        address.setCityName(citynamep);
        address.setStateName(statenamep);
        address.setCountryName(countrynamep);
        address.setCountryId(countryId);
    }

    public Phone getPhone() {
        return phone;
    }
    public void setPhone(int idp,String areacodep,String numberp,String extensionp) {
        phone = new Phone();
        phone.setId(idp);
        if (areacodep == null) {
            areacodep = "";
        }
        phone.setAreacode(areacodep);
        if (numberp == null) {
            numberp = "";
        }
        phone.setNumber(numberp);
        if (extensionp == null) {
            extensionp = "";
        }
        phone.setExtension(extensionp);
    }
    public void setPhone(int idp,int areacodeIdp,String numberp,String extensionp) {
        phone = new Phone();
        phone.setId(idp);
        phone.setAreacodeId(areacodeIdp);
        phone.setNumber(numberp);
        phone.setExtension(extensionp);
    }

    public Phone getFax() {
        return fax;
    }
    public void setFax(int idp,String areacodep,String numberp,String extensionp) {
        fax = new Phone();
        fax.setId(idp);
        fax.setAreacode(areacodep);
        fax.setNumber(numberp);
        fax.setExtension(extensionp);
    }

    public Url getWebSite() {
        return web_site;
    }
    public void setWebSite(int paramId,String param) {
        web_site = new Url();
        web_site.setId(paramId);
        web_site.setUrl(param);
    }

    public Url getEmail() {
        return email;
    }
    public void setEmail(String param) {
        email = new Url();
    }

    public Ressource getRessource() {
        return ressource;
    }
    public void setRessource(int id) {
        ressource = new Ressource();
        ressource.setId(id);
    }
    public void setRessource(int id,String param1,String param2) {
        ressource = new Ressource();
        ressource.setId(id);
        ressource.setFirstName(param1);
        ressource.setLastName(param2);
    }

    /** ALL TPC_OBJECT HAVE THOSE METHODS / FIELDS **/
    public int getLife() {
        return life;
    }
    public void setLife(int param) {
        life = param;
    }

    public Date getCreatedDate() {
        return created_date;
    }
    public void setCreatedDate(Date param) {
        created_date = param;
    }
    public String getCreatedDateAsString() {
        return "créé le "+createdDateString;
    }
    public void setCreatedDateAsString(String param) {
        createdDateString = param;
    }

    public int getCreatedBy() {
        return created_by;
    }
    public void setCreatedBy(int param) {
        created_by = param;
    }

    public Date getModifiedDate() {
        return modified_date;
    }
    public void setModifiedDate(Date param) {
        modified_date = param;
    }
    public String getModifiedDateAsString() {
        return "modifié le "+modifiedDateString;
    }
    public void setModifiedDateAsString(String param) {
        modifiedDateString = param;
    }

    public int getModifiedBy() {
        return modified_by;
    }
    public void setModifiedBy(int param) {
        modified_by = param;
    }
}
